package driver.model;

import java.sql.SQLException;
import java.util.ArrayList;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import to.DriverTO;


public class DriverDAO {
	private SqlMapClientTemplate sqlMap;
	public DriverDAO(SqlMapClientTemplate sqlMap){
		this.sqlMap = sqlMap;
	}
	
	public DriverTO selectDriverByPhone(String Phone) throws SQLException{
		return (DriverTO)sqlMap.queryForObject("selectDriverByPhone", Phone);
	}
	
	public DriverTO selectDriver(String phone) throws SQLException{
		return (DriverTO) sqlMap.queryForObject("selectDriver", phone);
	}
	
	//회원 정보를 DB에 insert하는 메소드
	public void insertDriver(DriverTO dto) throws SQLException{
		sqlMap.insert("insertDriver", dto);
	}
	
	//회원정보 삭제
	public void deleteDriverByPhone(String Phone) throws SQLException{
		sqlMap.delete("deleteDriverByPhone", Phone);
	}
	
	//전체 회원정보 조회
	@SuppressWarnings("unchecked")
	public ArrayList<DriverTO> selectAllDriver() throws SQLException{
		return (ArrayList<DriverTO>) sqlMap.queryForList("selectAllDriver");
	}
	
	//회원정보 수정
	public void updateDriver(DriverTO dto) throws SQLException{
		sqlMap.update("updateDriver", dto);
	}
	
}
